use bytes::{Buf, BufMut, BytesMut};
use log::info;

#[test]
fn bytes_mut_test1() {
    let mut bytes_mut = BytesMut::new();
    bytes_mut.put_i32(12);
    bytes_mut.put_u16(11);

    let t1 = bytes_mut.get_i32();
    assert_eq!(t1, 12);
    bytes_mut.put_u16(1);
    let mut b2 = bytes_mut.split();
    info!("b2 length: {:?}", b2.capacity());
    info!("b1 length: {:?}", bytes_mut.capacity());
    let t2 = b2.get_u16();
    assert_eq!(t2, 11);
    let t3 = b2.get_u16();
    assert_eq!(t3, 1);
}

#[test]
fn bytes_mut_test2() {
    let mut bytes_mut = BytesMut::new();
    bytes_mut.put_i32(12);
    bytes_mut.put_u16(11);

    let t1 = bytes_mut.get_i32();
    assert_eq!(t1, 12);
    bytes_mut.put_u16(1);
    let b2 = bytes_mut.split();
    info!("b2 length: {:?}", b2.len());
    info!("b1 length: {:?}", bytes_mut.capacity());
}